Skip to content

Conversation

@Fletterio
Copy link
Contributor

Description

Adds a new class for 2,3 and 4-dimensional morton codes, with arithmetic and comparison operators

Testing

TODO

TODO list:

Need to make sure all operators work properly before merging


NBL_CONSTEXPR_FUNC T operator()(NBL_CONST_REF_ARG(T) operand)
{
return -operand;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it need to be operand.operator-() because of HLSL?

or maybe you want to do a partial spec with requires Fundamental<T> and requires !Fundamental<T> where you do operator-() call ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +78 to +79
template<>
struct is_emulating_integral_scalar<emulated_uint64_t>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where's the primary template declaration?

btw you could actually replace impl::is_emulating_integral_scalar with just ImitationIntegral64Scalar concept

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is below is_emulating_floating_point_scalar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use the EmulatedIntegral64Scalar concept and call it a day, one less thing in impl

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_emulating_integral_scalar might be needed if we want to emulate uint128_t in the future. Or this is unlikeyly?


template<typename Scalar, typename U>
struct Promote<vector <Scalar, 2>, U>
// TODO(kevinyu): Should we enable truncation from uint64_t to emulated_vector<emulated_uint64_t, N>?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

promotion yes, allow it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
};

// The default version above only works for fundamental scalars, vectors and matrices. This is because you can't call `~x` unless `x` is one of the former.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then constrain the version above to only do FundamentalType

the thing which you have as a specialization you should have as the general case, and the general you should have as a specialization

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_fundamental_v is set to is_scalar_v or void. Should we add fundamental to include concepts::Vector and concepts::Matrix?

Comment on lines 273 to 282
template<typename T NBL_STRUCT_CONSTRAINABLE >
struct ternary_operator
{
using type_t = T;

T operator()(bool condition, NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs)
NBL_CONSTEXPR_FUNC T operator()(NBL_CONST_REF_ARG(bool) condition, NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs)
{
return select<bool, T>(condition, lhs, rhs);
}
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm actually I noticed something, in C++ and HLSL the ? shortcircuits (whereas select shouldn't)

This means that ternary_operator can only be defined as

template<typename F1, typename F2> requires is_same_v<decltype(std::declval<F1>()()),decltype(std::declval<F2>()())>
struct ternary_operator
{
   using type_t = decltype(std::declval<F1>().operator());

   NBL_CONSTEXPR_FUNC type_t operator()(const bool condition, NBL_CONST_REF_ARG(F1) lhs, NBL_CONST_REF_ARG(F2) rhs)
   {
      if (condition)
         return lhs();
      else
         return rhs();
   }
};

simply to take lambdas and short-circuit (not call/evaluate the branch that is false)

so sorry about telling you to reimplement ternary_operator in terms of select
(but most ccrrent uses of ternary_operator should be replaced with select)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Nabla itself there should only be this, which needs to change to select_helper partial spec

struct ternary_operator< complex_t<Scalar> >

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#define NBL_CONSTEXPR_OOL_MEMBER const
#define NBL_CONSTEXPR_INLINE_OOL_MEMBER const
#define NBL_IF_CONSTEXPR(...) if (__VA_ARGS__)
#define NBL_ASSERT(...)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wel aready have a shader assert somwhere, it does a vk::RawBufferStore to an invalid (0) BDA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NBL_CONSTEXPR_FUNC bool verifyAnyBitIntegralVec(vector<T, Dim> vec)
{
array_get<vector<T, Dim>, T> getter;
[[unroll]]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NBL_UNROLL or it won't compile in C++

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see

#define NBL_UNROLL [[unroll]]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants